(function($){
	if(typeof Object.assign != "function"){
		Object.assign = function(target){
			"use strict";
			if(target == null) {
				throw new TypeError("Cannot convert undefined or null to Object");
			}
			
			target = Object(target);
			for(var index = 1; index < arguments.length; index++) {
				var source = arguments[index];
				if(source != null) {
					for(var key in source) {
						if(Object.prototype.hasOwnProperty.call(source,key)){
							target[key] = source[key];
						}
					}
				}
			}
			return target;
		};
	}
})(jQuery);
//from表单序列化成json
$.fn.serializeObject = function () {
    var o = {};
    var a = this.serializeArray();
    $.each(a, function () {
        if (o[this.name] !== undefined) {
            if (!o[this.name].push) {
                o[this.name] = [o[this.name]];
            }
            o[this.name].push(this.value || '');
        } else {
            o[this.name] = this.value || '';
        }
    });
    return o;
};

//日期格式转换
Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
    }
    return fmt;
};


/**
 * @function escapeHTML 转义html脚本 < > & " '
 * @param s -
 *            字符串
 */
function escapeHTML(s) {
    s = "" + s;
    return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
}

/**
 * @function unescapeHTML 还原html脚本 < > & " '
 * @param s -
 *            字符串
 */
function unescapeHTML(s) {
    s = "" + s;
    return s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
}

/**
 * 秒转成时分秒的形式
 * @param value
 * @returns {string}
 */
function formatSeconds(value) {
    var secondTime = parseInt(value);// 秒
    var minuteTime = 0;// 分
    var hourTime = 0;// 小时
    if (secondTime > 60) {//如果秒数大于60，将秒数转换成整数
        //获取分钟，除以60取整数，得到整数分钟
        minuteTime = parseInt(secondTime / 60);
        //获取秒数，秒数取佘，得到整数秒数
        secondTime = parseInt(secondTime % 60);
        //如果分钟大于60，将分钟转换成小时
        if (minuteTime > 60) {
            //获取小时，获取分钟除以60，得到整数小时
            hourTime = parseInt(minuteTime / 60);
            //获取小时后取佘的分，获取分钟除以60取佘的分
            minuteTime = parseInt(minuteTime % 60);
        }
    }
    var result = "" + parseInt(secondTime) + "秒";

    if (minuteTime > 0) {
        result = "" + parseInt(minuteTime) + "分" + result;
    }
    if (hourTime > 0) {
        result = "" + parseInt(hourTime) + "时" + result;
    }
    return result;
}

var editingRow = {tableId: undefined, index: undefined};

/**
 * 结束编辑状态并保存当前值
 * @param tagId 标签id
 * @returns {boolean}
 */
function endEditing(tableId) {
    if (editingRow.tableId == undefined || editingRow.index == undefined) {
        return true
    }
    if ($('#' + tableId).datagrid('validateRow', editingRow.index)) {
        $('#' + tableId).datagrid('endEdit', editingRow.index);
        editingRow.index = undefined;
        editingRow.tableId = undefined;
        return true;
    } else {
        $.messager.alert("错误", "您有信息未填写完善", "error");
        return false;
    }
}

/**
 * 添加一列
 * @param tableId
 */
function addRow(tableId) {
    if (endEditing(tableId)) {
        $('#' + tableId).datagrid('appendRow', {"action": "editing"});
        editingRow.tableId = tableId;
        editingRow.index = $('#' + tableId).datagrid('getRows').length - 1;
        $('#' + tableId).datagrid('selectRow', editingRow.index)
            .datagrid('beginEdit', editingRow.index);
    }
}

/**
 * 保存一列数据
 * @param tableId
 * @param index
 * @param url
 */
function saveRow(tableId, index, url) {
    if (endEditing(tableId)) {
        var row = $("#" + tableId).datagrid('selectRow', index).datagrid('getSelected');
        var method = row.mid ? "edit" : "add";
        App.post(url + method, row, function (result) {
            // result = JSON.parse(result);
            if(result && result.success){
                if (result.response) {
                    row.mid = result.response.mid;
                    row.action = "edited";
                    $("#" + tableId).datagrid('refreshRow', index);
                }
                toastr["success"]("提交成功", "", function () {
                });
            } else {
                $.messager.alert("保存失败", result.msg, "error");
            }
        });
    }
}

/**
 * 删除选中列
 * @param tagId
 */
function deleteRow(tableId, index, url) {
    var row = $("#" + tableId).datagrid('selectRow', index).datagrid('getSelected');
    if (row.mid) {
        App.remove(row.mid, url, function () {
            $('#' + tableId).datagrid('deleteRow', index);
            editingRow.index = undefined;
        });
    } else {
        $('#' + tableId).datagrid('deleteRow', index);
        editingRow.index = undefined;
    }
}

/**
 * 编辑当前列
 * @param index
 * @param row
 * @param tagId
 */
function editRow(tableId, index) {
    if (tableId != editingRow.tableId || index != editingRow.index) {
        if (endEditing(tableId)) {
            $("#" + tableId).datagrid('selectRow', index);
            $("#" + tableId).datagrid('getSelected').action = "editing";
            $("#" + tableId).datagrid('refreshRow', index);
            $("#" + tableId).datagrid('beginEdit', index);
            editingRow.tableId = tableId;
            editingRow.index = index;
        } else {
            setTimeout(function () {
                $("#" + tableId).datagrid('selectRow', editingRow.index);
            }, 0);
        }
    }
}

if (App) {
    /**
     * 统一封装的ajax get请求
     * @param url 请求地址
     * @param resolve 请求成功的回掉函数
     * @param reject 请求失败的回掉函数
     */
    App.get = function (url, resolve, reject, headers) {
        $.ajax({
            type: "get",
            dataType: "json",
            url: url,
            cache: false,
            headers: headers,
            success: function (result) {
                if (result && result.success === false && reject) {
                    reject(result.msg, result.obj?result.obj:result.response);
                } else {
                    if (resolve) {
                        resolve(result);
                    }
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log(jqXHR.responseText);
                if (401 == jqXHR.status || 403 == jqXHR.status) {
                    window.location.href = "/error/" + jqXHR.status;
                } else if (reject) {
                    reject(jqXHR.responseText);
                }
            }
        });
    };

    /**
     * 获取 对象实体
     * @param url
     * @param resolve
     * @param reject
     */
    App.getEntity = function (url, resolve, reject) {
        $.ajax({
            type: "get",
            dataType: "json",
            url: url,
            cache: false,
            success: function (result) {
                resolve(result);
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log(jqXHR.responseText);
                if (401 == jqXHR.status || 403 == jqXHR.status) {
                    window.location.href = "/error/" + jqXHR.status;
                } else if (reject) {
                    reject(jqXHR.responseText);
                }
            }
        });
    };


    /**
     * 统一封装的ajax post请求
     * @param url 请求地址
     * @param body 请求体
     * @param resolve 请求成功的回掉函数
     * @param reject 请求失败的回掉函数
     */
    App.post = function (url, body, resolve, reject, multipart, contentType, headers) {
		body = App.delProperty(body,"@type", Infinity);
        var ajaxOption = {
            type: "post",
            dataType: "json",
            url: url,
            data: body,
            cache: false,
            headers: headers,
            processData: !multipart,
            contentType: contentType || (multipart ? false : 'application/x-www-form-urlencoded'),
            success: function (result) {
                if (result && result.success === false && reject) {
                    reject(result.msg, result.obj?result.obj:result.response);
                } else {
                    if (resolve) {
                        resolve(result);
                    }
                }
            },
            error: function (jqXHR, textStatus, errorThrown) {
                console.log(jqXHR.responseText);
                if (401 == jqXHR.status || 403 == jqXHR.status) {
                    window.location.href = "/error/" + jqXHR.status;
                } else if (reject) {
                    reject(jqXHR.responseText);
                }
            }
        };

        $.ajax(ajaxOption);
    };

    /**
     * 统一封装的ajax post请求
     * @param url 请求地址
     * @param data 请求体
     * @param resolve 请求成功的回掉函数
     * @param reject 请求失败的回掉函数
     */
    App.postJson = function (url, data, resolve, reject, headers) {
		if(typeof data != "string"){
			data = JSON.stringify(data);
		}
        App.post(url, data, resolve, reject, false, "application/json;charset=UTF-8", headers);
    };

    /**
     * 统一封装的ajax get请求
     * @param url 请求地址
     * @param data 请求体
     * @param resolve 请求成功的回掉函数
     * @param reject 请求失败的回掉函数
     */
    App.getJson = function (url, resolve, reject, headers) {
        headers = headers || {};
        headers["Content-Type"] = "application/json;charset=UTF-8";
        App.get(url, resolve, reject, headers);
    };

    /**
     * 导出并下载文件,支持导出多个文件
     * @param url
     * @param data
     */
    App.batchExport = function (url, data) {
        App.blockUI({
            boxed: true,
            message: "处理中..."
        });
        App.post(url, data, function (result) {
            App.unblockUI();
            if (Array.isArray(result.response)) {
                result.response.forEach(function (downUrl,index) {
                    App.download(downUrl, index);
                });
            } else {
                App.download(result.response, 0);
            }
        }, function (error) {
				toastr["error"](error, "下载失败");
            App.unblockUI();
        });
    };

    App.download = function (url, name) {
        if (!!window.ActiveXObject || 'ActiveXObject' in window) {
            window.open(url, '_blank')
        } else {
            var a = document.createElement("a"), //创建a标签
                e = document.createEvent("MouseEvents"); //创建鼠标事件对象
            e.initEvent("click", false, false); //初始化事件对象
            a.href = url; //设置下载地址
            a.download = name; // 设置下载文件名
            a.dispatchEvent(e); //给指定的元素，执行事件click事件
        }
    };

    /**
     * easyui弹窗自动创建控件
     * @param element 作用范围
     */
    App.easyuiParse = function (element) {
        $.parser.parse(element);
    };
    /**
     * sweetAlert封装
     */
    App.sweetAlert = top.sweetAlert;


    App.popup = function (id, title, url, width, height, params, buttons, readOnly) {
        $("#" + id + "_text").keydown(function () {
            var val = this.value;
            this.value = val;
        });

        buttons = buttons ? buttons : {};
        buttons.main = {
            label: "确定",
            className: "blue",
            callback: function () {
                var selectNodes = top.window.getData();
                var returnData = {};
                for (var i = 0; i < selectNodes.length; i++) {
                    for (var name in params) {
                        if (returnData[name]) {
                            returnData[name] += ",";
                        } else {
                            returnData[name] = "";
                        }
                        returnData[name] += selectNodes[i][params[name]];
                    }
                }
                for (var name in returnData) {
                    $("#" + name).val(returnData[name]);
                }
            }
        };
        buttons = readOnly ? {} : buttons;

        var className = App.getUniqueID("popup");
        if (top.$("#dialogStyle").length == 0) {
            top.$("body").append("<style id='dialogStyle'></style>");
        }

        var htmlStr = top.$("#dialogStyle").html();
        top.$("#dialogStyle").html(htmlStr + "." + className + "{width:" + width + "px;height: " + height + "px;margin-left:" + ((App.getWindowSize(top).winWidth - width) / 2) + "px;margin-top: " + ((App.getWindowSize(top).winHeight - height) / 2) + "px;}");
        $("#" + id + "_text,#" + id + "_a").click(function () {
            top.window.dialogData = $("#" + id).val();
            top.window.setText = function (texts) {
                $("#" + id + "_text").val(texts);
            };
            App.dialog(url, title, className, buttons);
        });
    };
    /**
     * 对话框
     * @param url 对话框内容页面地址
     * @param title 对话框标题
     * @param className 对话框类名
     * @param buttons 对话框按钮
     */
    App.dialog = function (url, title, className, buttons) {
        var dialog = top.bootbox.dialog({
            message: '<iframe src="' + url + '" frameborder="no" border="no" scrolling="auto" width="100%" height="100%"></iframe>',
            title: title,
            className: className,
            buttons: buttons
        });
    };
    /**
     *
     * @param id 提交按钮id
     * @param formId form表单id
     * @param messages 验证不通过信息
     * @param rules 验证规则
     */
    App.submit = function (id, formId, url, messages, rules, successMethod, errorMethod, beforeMethod) {
        $("#" + formId).validate({
            errorElement: "span",
            errorClass: "help-block help-block-error",
            focusInvalid: !1,
            ignore: "",
            messages: messages,
            rules: rules,
            errorPlacement: function (e, r) {
                r.is(":checkbox") ? e.insertAfter(r.closest(".md-checkbox-list, .md-checkbox-inline, .checkbox-list, .checkbox-inline")) : r.is(":radio") ? e.insertAfter(r.closest(".md-radio-list, .md-radio-inline, .radio-list,.radio-inline")) : e.insertAfter(r)
            },
            highlight: function (e) {
                $(e).closest(".form-group").addClass("has-error")
            },
            unhighlight: function (e) {
                $(e).closest(".form-group").removeClass("has-error")
            },
            success: function (e) {
                e.closest(".form-group").removeClass("has-error");
            }
        });

        if (id) {
            //清除以前的事件，绑定最新的事件
            $("#" + id).unbind();
            $("#" + id).click(function () {
                $("#" + formId).submit();
            });
        }
        $("#" + formId).submit(function () {
            /**
             * 判断 beforeMethod 是否传入 如果没有传入 不执行
             */
            if (typeof beforeMethod == "function") {
                beforeMethod();
            }


            App.blockUI({
                boxed: true,
                message: "处理中..."
            });
            $("#" + formId + " .form-control").attr("disable", "disable");
            if ($("#" + formId).valid()) {
                App.post(url, $("#" + formId).serialize(), function (result) {
                    App.unblockUI();
                    if (result && result.success) {
                        if (typeof successMethod == 'function') {
                            successMethod(result);
                        }
                    } else {
                        if (typeof errorMethod == 'function') {
                            errorMethod(result.msg);
                        }
                    }
                }, function (error) {
                    App.unblockUI();
                    $("#" + formId + " .form-control").removeAttr("disable");
                    if (typeof errorMethod == 'function') {
                        errorMethod(error);
                    }
                });
            } else {
                App.unblockUI();
                $("#" + formId + " .form-control").removeAttr("disable");
            }
            return false;
        });
    };


    /**
     * 填充一个DIV 中所有input框的数据
     * @param divId
     * @param dataSet
     * @param primaryKeyId 主键Id 【考虑到有时候弹框中的主键Id会跟主页面的Id重复】
     */
    App.fillData = function (divId, dataSet, primaryKeyId) {
        for (var jsonKey in dataSet) {
            if (jsonKey == "mid") {
                $("#" + primaryKeyId + "").val(dataSet[jsonKey]);
            }
            App.setVal(jsonKey, dataSet[jsonKey], divId);
        }

    };

    /******
     * 给指定 div中的 元素赋值
     * @param key   元素IIid
     * @param val   值
     * @param divid 指定的div id
     */
    App.setVal = function (key, val, divId) {
        /**循环赋值input、textarea**/
        $("#" + divId + " input,textarea").each(
            function () {
                if ($(this)[0].id == key) {
                    if (val == undefined) {
                        val = "";
                    }
                    $(this).val(val);
                }
            }
        );

    };

    //冒泡提示
    App.publicBubble = function (data, row, index) {
        if (undefined !== data) {
            return "<sapn title='" + data + "'>" + data + "</sapn>";
        } else {
            return "";
        }
    };

    /**
     * 清空指定div中所有的输入框的值
     * @param divId  指定的div id
     */
    App.clearVal = function (divId) {
        /**循环赋值input、textarea**/
        $("#" + divId + " input,textarea").each(
            function () {
                $(this).val("");
            }
        );

    };

    /**
     * 清空指定div中所有的输入框的值 带有排除项
     * @param divId  指定的div id
     * @param exclusion 排除的div 字符串数组
     */
    App.clearValHasExclusion = function (divId, exclusion) {
        /**循环赋值input、textarea**/
        $("#" + divId + " input,textarea").each(
            function () {
                if (exclusion.indexOf(this.id) < 0) {
                    $(this).val("");
                }
            }
        );

    };

	/**
	 * 跳转详情页
	 * @param mid
	 * @param url
	 * @param backUrl
	 * @param openModel 1 当前页面打开 2 弹窗打开 3 tab页提交
	 * @param callback 弹窗回写
	 * @param width 弹窗宽度 默认800
	 * @param height 弹窗高度 默认 500
	 * @param tabName 标签页名
	 */
    App.detail = function (mid, url, backUrl, openModel, callback, width, height, tabName) {
        if (!openModel) openModel = 1;
        if (!backUrl) backUrl = location.href;
        if (openModel == 1) {
			if (url) {
				url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);
			} else {
				url = "detail?mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);
			}
            location.href = url
        } else if (openModel == 2) {
			if (url) {
			    url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid + "&openModel=2";
			} else {
			    url = "detail?mid=" + mid + "&openModel=2";
			}
			if (!width) width = 800;
			if (!height) height = 500;
			$("<div></div>").modalDialog({
			    title: '详情',
			    url: url,
			    width: width,
			    height: height,
			    callBack: callback
			}).click();
        } else if (openModel == 3) {
			if (url) {
                if(Array.isArray(url)) {
                    url[0] = url[0] + (url[0].indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);;
                } else {
                    url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);;
                }
			} else {
				url = "detail?mid=" + mid;
			}
			top.window.test.implementRefresh(url,tabName);
        } else {
        }
    };

    App.poDetail = function (mid, url, width, height) {
        if (url) {
            url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid;
        } else {
            url = "detail?mid=" + mid;
        }
        if (width || height) {
            var size = 'width=' + width + 'px;height=' + height + 'px;';
        } else {
            var size = 'fullscreen=yes;';
        }
        POBrowser.openWindowModeless(url, size)
    };

    App.edit = function (mid, url, backUrl, openMode, windowName) {
        if (!backUrl) backUrl = location.href;
        if (url) {
            if(Array.isArray(url)) {
                url[0] = url[0] + (url[0].indexOf("?") >= 0 ? "&" : "?") + "method=edit&mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);
            } else {
                url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "method=edit&mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);
            }
        } else {
            url = "detail?method=edit&mid=" + mid + '&backUrl=' + encodeURIComponent(backUrl);
        }
        if ("newTab" == openMode) {
            top.window.test.implementRefresh(url, windowName);
        } else {
            location.href = url
        }
    };

    App.poEdit = function (mid, url, width, height) {
        if (url) {
            url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "method=edit&mid=" + mid;
        } else {
            url = "detail?method=edit&mid=" + mid;
        }
        if (width || height) {
            var size = 'width=' + width + 'px;height=' + height + 'px;';
        } else {
            var size = 'fullscreen=yes;';
        }
        POBrowser.openWindowModeless(url, size)
    };

    App.add = function add(url, backUrl, openMode, windowName) {
        if (!backUrl) backUrl = location.href;
        if (url) {
            if(Array.isArray(url)) {
                url[0] = url[0] + (url[0].indexOf("?") >= 0 ? "&" : "?") + "method=add" + '&backUrl=' + encodeURIComponent(backUrl);
            } else {
                url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "method=add" + '&backUrl=' + encodeURIComponent(backUrl);
            }
        } else {
            url = "detail?method=add" + '&backUrl=' + encodeURIComponent(backUrl);
        }
        if ("newTab" == openMode) {
            top.window.test.implementRefresh(url, windowName);
        } else {
            location.href = url;
        }
    };

    App.poAdd = function add(url, width, height) {
        if (url) {
            url = url + (url.indexOf("?") >= 0 ? "&" : "?") + "method=add";
        } else {
            url = "detail?method=add";
        }
        if (width || height) {
            var size = 'width=' + width + 'px;height=' + height + 'px;';
        } else {
            var size = 'fullscreen=yes;';
        }
        POBrowser.openWindowModeless(url, size)
    };

    App.remove = function (mid, url, callBack) {
        var self = this;
        $.messager.confirm(
            "确认删除？",
            "",
            "warning",
            function () {
                App.blockUI({
                    boxed: true,
                    message: "处理中..."
                });
                self.post(url ? url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid : "delete?mid=" + mid,
                    null,
                    function (result) {
                        App.unblockUI();
                        $.messager.alert("删除成功", "", "success", function () {
                            if (callBack) {
                                callBack();
                            } else {
                                search();
                            }
                        });
                    }, function (error) {
                        App.unblockUI();
                        $.messager.alert("删除失败", error, "error");
                    });
            });
    };

    //提交审批
    App.apply = function (tableId, formId, url, isDefVili) {
        if (!tableId) tableId = "table";
        if (!url) url = "apply";
        var rows = $("#" + tableId).datagrid("getChecked");
        if (rows.length == 1) {
            $.messager.confirm("数据提交审批警告", "请确认是否提交审批数据？", function (boo) {
                if (boo) {
                    App.blockUI({
                        boxed: true,
                        message: "处理中..."
                    });
                    var row = rows[0];
                    delete row["@type"];
					if(isDefVili && !(row.processStatus === undefined || row.processStatus === null || row.processStatus === "") && rows.processStatus > 0 ) {
						toastr["warning"](row.title + "审批中或已完成审批!", "提示");
						return;
					}
                    App.post(url, row, function (result) {
                        App.unblockUI();
                        $.messager.alert("提交成功", "", "success", function () {
                            public_js.search(formId, tableId);
                        });
                    }, function (error) {
                        App.unblockUI();
                        $.messager.alert("提交失败", error, "error");
                    });
                }
            });
        } else if (rows.length > 1) {
            $.messager.alert("只能选择一项数据！", error, "warning");
        } else {
            $.messager.alert("请选择一项数据！", error, "warning");
        }
    };
    //导入
    App.import = function (url) {
        if (!url) url = "import";
        $("<div></div>").modalDialog({
            title: '导入',
            url: url,
            width: 800,
            height: 500
        }).click();
    };
    //导出
    App.export = function (tableId, url) {
        if (!tableId) tableId = "table";
        var rows = $("#" + tableId).datagrid("getChecked");
        if (rows.length == 1) {
            location.href = url ? url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + rows[0].mid : "export?mid=" + rows[0].mid;
        } else if (rows.length > 1) {
            $.messager.alert("只能选择一项数据！", "提示", "warning");
        } else {
            $.messager.alert("请选择一项数据！", "提示", "warning");
        }
    };

    App.invalid = function (mid, url, callBack) {
        var self = this;
        $.messager.confirm(
            "确认删除？",
            "",
            "warning",
            function () {
                App.blockUI({
                    boxed: true,
                    message: "处理中..."
                });
                self.post(url ? url + (url.indexOf("?") >= 0 ? "&" : "?") + "mid=" + mid : "invalid?mid=" + mid,
                    null,
                    function (result) {
                        App.unblockUI();
                        $.messager.alert("删除成功", "", "success", function () {
                            if (callBack) {
                                callBack();
                            } else {
                                search();
                            }
                        });
                    }, function (error) {
                        App.unblockUI();
                        $.messager.alert("删除失败", error, "error");
                    });
            });
    };

    App.getWindowSize = function (window) {
        var winWidth;
        var winHeight;
        if(window.innerWidth === 0) {
            var choiceFrame = $("#contentPane .active .content_iframe",top.window.document);
            if(choiceFrame.length > 0){
                window = choiceFrame[0].contentWindow;
            }
        }
        // 获取窗口宽度
        if (window.innerWidth)
            winWidth = window.innerWidth;
        else if ((document.body) && (document.body.clientWidth))
            winWidth = document.body.clientWidth;
        // 获取窗口高度
        if (window.innerHeight)
            winHeight = window.innerHeight;
        else if ((document.body) && (document.body.clientHeight))
            winHeight = document.body.clientHeight;
        // 通过深入 Document 内部对 body 进行检测，获取窗口大小
        if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
            winHeight = document.documentElement.clientHeight;
            winWidth = document.documentElement.clientWidth;
        }
        return {"winWidth": winWidth, "winHeight": winHeight};
    };

    /**
     * 获取Portlet内部可用高度，适合整个页面只有一个portlet且有portletTitle的高度计算
     * @returns {number}
     */
    App.getPortletInnerHeight = function () {
        var windowHeight = App.getWindowSize(window).winHeight;
        var portletTitleHeight = 35;
        var portletBodyPaddingHeight = 10;
        var portletPaddingHeight = 15;
        var pageContentPaddingHeight = 20;
        return windowHeight - portletTitleHeight - portletBodyPaddingHeight - portletPaddingHeight - pageContentPaddingHeight;
    };

    //打印
    App.print = function (id) {
        // 获取原来的窗口界面body的html内容，并保存起来
        // 获取div中的html内容
        $(".page-wrapper").css("visibility", "hidden");
        var clone = $("#" + id).clone(true);
        clone.find("input").each(function () {
            $(this).parent().html($(this).val());
        });
        $("#printDiv").append(clone);
        // 调用window.print方法打印新窗口
        window.print();

        // 将原来窗口body的html值回填展示
        $("#printDiv").html("");
        $(".page-wrapper").css("visibility", "visible");
    };

    //获取URL中的查询参数
    App.getQueryString = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return decodeURIComponent(r[2]);
        }
        return null;
    };
	/** bs端监听通信
	 * @param {Object} type 通信类型
	 * @param {Object} data 通信数据
	 */
	App.ipcWatch = function(type,data){
		switch(type){
			case top.window.ipcEnum.FAIL: //下载失败
				App.downloadStatusSet(data.mid,0);
				break;
			case top.window.ipcEnum.CANCEL: //取消下载
				App.downloadStatusSet(data.item.mid,2);
				break;
			case top.window.ipcEnum.SUCCESS: //下载完成
				App.downloadStatusSet(data.mid,3);
				break;
		}
	};
	/**报告附件下载状态更新
	 * @param {Object} mid 任务下载mid
	 * @param {Object} downloadStatus 下载状态 0 下载失败  1 正在下载  2 取消下载  3 下载完成
	 * @param {Object} resolve 成功后的回调函数
	 * @param {Object} reject 失败后的回调函数
	 */
	App.downloadStatusSet = function(mid, downloadStatus, resolve, reject){
		if(!mid && !downloadStatus){
			toastr["warning"]("没有相关报告附件下载状态需要更新!", "提示");
			return;
		}
		App.blockUI({
			boxed: true,
			message: "处理中..."
		});
		App.post("/reportmanage/reportFileDownload/save",{
			mid: mid,
			downloadStatus: downloadStatus
		},function(result){
	        App.unblockUI();
			if(resolve) resolve(result);
		},function(error){
	        App.unblockUI();
			console.log(error);
			toastr["error"]("下载状态更新失败！", "提示");
			if(reject) reject(error);
		});
	};
	/**下载记录生成  
	 * @param {Object} reportAttachmentArrayStr 任务单的mid，台账下载必传，详情下载不传
	 * @param {Object} reportFileDownloadArrayStr 文件下载列表字符串
	 * @param {Object} resolve 成功后的回调函数
	 * @param {Object} reject 失败后的回调函数
	 */
	App.addDownloadRecord = function(reportAttachmentArrayStr, reportFileDownloadArrayStr, resolve, reject){
		if(!reportAttachmentArrayStr && !reportFileDownloadArrayStr){
			toastr["warning"]("没有相关报告需要下载!", "提示");
			return;
		}
		App.blockUI({
			boxed: true,
			message: "处理中..."
		});
		var data = {};
		if(reportAttachmentArrayStr) data.reportAttachmentArrayStr = reportAttachmentArrayStr;
		if(reportFileDownloadArrayStr) data.reportFileDownloadArrayStr = reportFileDownloadArrayStr;
		App.postJson("/reportmanage/reportTaskDownload/addDownloadRecord",data,function(result){
	        App.unblockUI();
			if(result.response && result.response.length){
				toastr["success"]("报告附件下载开始，记录生成成功！", "提示");
				if(top.window.renderIpc) top.window.renderIpc.send(top.window.ipcEnum.DOWNLOAD, result.response);
				if(resolve) resolve(result);
			} else {
				toastr["warning"]("勾选的报告没有能下载的附件！", "提示");
			}
		},function(error){
	        App.unblockUI();
			console.log(error);
			toastr["error"]("报告附件下载失败！", "提示");
			if(reject) reject(error);
		});
	};
	/**
	 * @param {Object} data 数据 可以是数组、对象、JSON字符串
	 * @param {Object} properties 要删除的字段
	 * @param {Object} level 要删到那一层 层级是以对象为标准，数组和JSON字符串进入层级计算，默认为1，Infinity为无限
	 */
	App.delProperty = function (data,properties,level){
		if(typeof properties === "string") properties = properties.split(",");
		else if(!Array.isArray(properties) || !properties.length) return data;
		if(!level) level = 1;
		function delPropertyByKey(data){
			if(Array.isArray(data)){
				for(var i = 0; i < data.length; i++) {
					data[i] = delPropertyByKey(data[i]);
				}
			} else if(typeof data === "object") {
				if(level !== Infinity) level--;
				for(var key in data) {
					if(properties.indexOf(key) != -1) delete data[key];
					else if(level === Infinity || level > 0) data[key] = delPropertyByKey(data[key]);
				}
			} else if(typeof data === "string" && data.indexOf("{") != -1){
				try{
					data = JSON.parse(data);
					data = JSON.stringify(delPropertyByKey(data));
				} catch(e){}
			}
			return data;
		}
		return delPropertyByKey(data);
	}
} else {
    throw "App is not loaded, must loaded first";
}

$(function () {
    if ($('.portlet .tools .collapse').length > 0) {
        $(".portlet").on("mouseover", ".tools .collapse", function () {
            var hoverMsg = $(this).attr("aria-describedby");
            $("#" + hoverMsg).hide();
        });
    }
    ;
    if ($('table').hasClass('table-hover')) {
        $('table').removeClass('table-hover');

    }
    ;
});
// $("table").on("click","tbody tr",function(){
//     $(this).siblings().removeClass('selected');
// })
function changeInputBack(type) {
    if (type) {
        $("input[readonly='readonly']").css('background-color', 'white');
        $("input[disabled='disabled']").css('background-color', 'white');
        $("select[disabled='disabled']").css('background-color', 'white');

    } else {
        $("input[readonly='readonly']").css('background-color', 'rgba(0,0,0,.1)');
        $("input[disabled='disabled']").css('background-color', 'rgba(0,0,0,.1)');
        $("select[disabled='disabled']").css('background-color', 'rgba(0,0,0,.1)');
    }
}

var nowFilterTable = null;//当前正在进行模糊查询的表格
$(function () {
var _$timeout = null;
    $("body").on('keydown', '.modal-scrollable .modal-content .modal-body input', function (ev) {
        if (ev.keyCode == 13) {
            return false;
        }
    });
    //表格模糊查询enter按键监听
    $("body").on('keydown', function (ev) {
        if (ev.keyCode == 13 && nowFilterTable != null) {
			if(_$timeout) {
				clearTimeout(_$timeout);
				_$timeout = null;
			}
			_$timeout = setTimeout(function(){
				clearTimeout(_$timeout);
				_$timeout = null;
				var nowFilterTable_name = '';
				if ($(nowFilterTable).data('treegrid')) {
					nowFilterTable_name = 'treegrid';
				} else {
					nowFilterTable_name = 'datagrid';
				}
				var opts = $(nowFilterTable)[nowFilterTable_name]('options');
				if (opts.automaticPolling === false) {
					$(nowFilterTable)[nowFilterTable_name]('doFilter');
				}
			},400)
        }
    });


    $("body").on('keyup', '.modal-scrollable .modal-content .modal-body input', function (ev) {
        if (ev.keyCode == 13 && $(this).parents('form').find("a:contains('查询')").length > 0) {
			if(_$timeout) {
				clearTimeout(_$timeout);
				_$timeout = null;
			}
			var that = this;
			_$timeout = setTimeout(function(){
				clearTimeout(_$timeout);
				_$timeout = null;
				$(that).parents('form').find("a:contains('查询')")[0].click();
			},400)
        }
    });

    $("a:contains('查询')").parents('form').on("keyup", "input", function (ev) {
        if (ev.keyCode == 13) {
			if(_$timeout) {
				clearTimeout(_$timeout);
				_$timeout = null;
			}
			var that = this;
			_$timeout = setTimeout(function(){
				clearTimeout(_$timeout);
				_$timeout = null;
				$(that).parents('form').find("a:contains('查询')")[0].click();
			},400)
        }
    });
});
var localStorageManage = {
    //往缓存中存数据
    setStorage: function (formId) {
        if (!formId) {
            formId = "searchForm";
        }
        if (!window.localStorage) {
            console.log("浏览器不支持localstorage");
        } else {
            var storageKey = "form_" + formId + "_" + window.location.pathname,
                formData = $("#" + formId).serializeObject();
            window.localStorage.setItem(storageKey, JSON.stringify(formData));
        }
    },
    //获取缓存中的数据
    getData: function (formId) {
        if (!formId) {
            formId = "searchForm";
        }
        var storageKey = "form_" + formId + "_" + window.location.pathname,
            storageddata = JSON.parse(window.localStorage.getItem(storageKey));
        return storageddata;
    },
    //往缓存中存数据--easyui版
    setStorageForEasyui: function (data, tableId) {
        if (!tableId) {
            tableId = "table";
        }
        if (!window.localStorage) {
            console.log("浏览器不支持localstorage");
        } else {
            var storageKey = "easyui_" + tableId + "_" + window.location.pathname;
            // formData = $("#" + filed).serializeObject();
            window.localStorage.setItem(storageKey, JSON.stringify(data));
        }
    },
    //获取缓存中的数据--easyui版
    getDataForEasyui: function (tableId) {
        if (!tableId) {
            tableId = "table";
        }
        var storageKey = "easyui_" + tableId + "_" + window.location.pathname,
			data = window.localStorage.getItem(storageKey),
            storageddata = !data ? null : JSON.parse(data);
        return storageddata;
    },
    //需要初始化form表单
    load: function (formId) {
        if (!formId) {
            formId = "searchForm";
        }
        var storageddata = this.getData(formId);
        for (var key in storageddata) {
            if ($("#" + formId).find("input[name='" + key + "']").length > 0) {
                $("#" + formId).find("input[name='" + key + "']").val(storageddata[key]);
            } else if ($("#" + formId).find("select[name='" + key + "']").length > 0) {
                $("#" + formId).find("select[name='" + key + "']").val(storageddata[key]);
            } else if ($("#" + formId).find("textarea[name='" + key + "']").length > 0) {
                $("#" + formId).find("textarea[name='" + key + "']").val(storageddata[key]);
            }
        }
    }
};

//easyui表格搜索框缓存
var easyuiLocalStorageManage = {
    //往缓存中存数据
    //TableID---tableid
    //data---input查询值
    easyuiSetStorage: function (data, TableID) {
        var inputData = data;
        if (!window.localStorage) {
            console.log("浏览器不支持localstorage");
        } else {
            var storageKey = "easyui_" + window.location.pathname;
            // formData = $("#" + filed).serializeObject();
            window.localStorage.setItem(storageKey, JSON.stringify(inputData));
        }
    },
    //获取缓存中的数据
    easyuiGetData: function (TableID) {
        // var opts = $('#'+TableID).datagrid('getColumnFields');	// get unfrozen columns
        // var optss= $('#'+TableID).datagrid('getColumnFields', true); // get frozen columns
        // var data=[];
        // for (a in opts){
        //     data.push(opts[a]);
        // }
        // for (b in optss){
        //     data.push(optss[b]);
        // }
        var data_List = [];
        var storageKey = "easyui_" + window.location.pathname;
        var storageddata = JSON.parse(window.localStorage.getItem(storageKey));
        for (j in storageddata) {
            var item = {};
            item[storageddata[j].field] = storageddata[j].value;
            data_List.push(item);
        }
        ;
        return data_List
    },
}

/**
 * 创建treeGrid三角小图标
 * id：为当前树id值
 * key: 当前节点的mid
 * url：后台ajax获取数据的地址
 * keyDataField：key名称
 */
function createTreeGridExpand(id, key, url, keyDataField) {
    var row = $("#" + id).jqxTreeGrid("getRow", key);
    var icon = '<i class="treegridExpand ';//这是固定
    if (row._expand) {
        icon += 'icon--53';
    } else {
        icon += 'icon--54';
    }
    icon += '" onclick="collapseOrExpand(this,';//这是固定
    icon += '\'' + id + '\',';//根据自己tree的id值更改
    icon += '\'' + key + '\',';//这是treegrid的keyDataField值
    icon += '\'' + url + '\',';//拼接后台ajax查询地址
    icon += '\'' + keyDataField + '\'';//拼接后台ajax查询地址
    icon += ')"></i>';//这是固定的
    return icon;
}

/**
 * treegrid 节点展开活收起
 * e：为当前图标dom
 * id：为当前树id值
 * key: 当前节点的mid
 * url：后台ajax获取数据的地址
 * keyDataField：key名称
 */
function collapseOrExpand(e, id, key, url, keyDataField) {
    var expand = $(e).parents("tr").find(".jqx-tree-grid-expand-button.jqx-grid-group-expand.jqx-icon-arrow-down");
    var collapse = $(e).parents("tr").find(".jqx-tree-grid-collapse-button.jqx-grid-group-collapse.jqx-icon-arrow-right");
    var row = $("#" + id).jqxTreeGrid("getRow", key);
    row._expand = false;
    if (expand && expand.length > 0) {
        $("#" + id).jqxTreeGrid('collapseRow', key);
        $("#" + id).jqxTreeGrid("updateRow", key, row);
    } else if (collapse && collapse.length > 0) {
        row._expand = true;
        $("#" + id).jqxTreeGrid('expandRow', key);
        $("#" + id).jqxTreeGrid("updateRow", key, row);
    } else {
        row._expand = true;
        var sdate = new Date();
        var isajax = $(e).attr("isajax");
        if (isajax) {
            return;
        }
        var isajax = $(e).attr("isajax", true);
        App.get(url, function (result) {
            if (result) {
                var keySet = [];
                for (var i = 0; i < result.length; i++) {
                    if (result[i].pid == key) {
                        keySet.push(result[i][keyDataField]);
                    }
                }
                $("#" + id).jqxTreeGrid("updateRow", key, row);
                $("#" + id).jqxTreeGrid('addRow', keySet, result, 'last', key);
                $("#" + id).jqxTreeGrid('expandRow', key);
                $(e).removeAttr("isajax");
                var edate = new Date();
                console.log((edate.getTime() - sdate.getTime()) / 1000 + 's');
            }
        }, function (msg) {
            console.log(msg)
        });
    }
}

function countTabContentHeight(otherHeight) {
    if (!otherHeight) {
        otherHeight = 0;
    }
    var page_content = $(".customer .page-content-wrapper .page-content").height();
    var tabTitle = $(".customer .page-content-wrapper .page-content>.row").outerHeight(true);
    return page_content - tabTitle - otherHeight;
}


function testExpand(e, id, key, url, keyDataField) {
    var expand = $(e).parents("tr").find(".jqx-tree-grid-expand-button.jqx-grid-group-expand.jqx-icon-arrow-down");
    var collapse = $(e).parents("tr").find(".jqx-tree-grid-collapse-button.jqx-grid-group-collapse.jqx-icon-arrow-right");

    var row = $("#" + id).jqxTreeGrid("getRow", key);
    row._expand = false;
    if (expand && expand.length > 0) {
        $("#" + id).jqxTreeGrid('collapseRow', key);
    } else if (collapse && collapse.length > 0) {
        row._expand = true;
        $("#" + id).jqxTreeGrid('expandRow', key);
    } else {
        var childData = [];
        var keySet = [];
        for (var i = 0; i < data.rows.length; i++) {
            if (data.rows[i].pid == key) {
                childData.push(data.rows[i]);
                keySet.push(data.rows[i].mid);
            }
        }
        $("#" + id).jqxTreeGrid('addRow', keySet, childData, 'last', key);
    }
    $("#" + id).jqxTreeGrid("updateRow", key, row);
}


$(function () {
    function banBackSpace(e) {
        var ev = e || window.event;
        //各种浏览器下获取事件对象
        var obj = ev.relatedTarget || ev.srcElement || ev.target || ev.currentTarget;
        //按下Backspace键
        if (ev.keyCode == 8) {
            var tagName = obj.nodeName //标签名称
            //如果标签不是input或者textarea则阻止Backspace
            if (tagName != 'INPUT' && tagName != 'TEXTAREA') {
                return stopIt(ev);
            }
            var tagType = obj.type.toUpperCase();//标签类型
            //input标签除了下面几种类型，全部阻止Backspace
            if (tagName == 'INPUT' && (tagType != 'NUMBER' && tagType != 'SEARCH' && tagType != 'TEXT' && tagType != 'TEXTAREA' && tagType != 'PASSWORD')) {
                return stopIt(ev);
            }
            //input或者textarea输入框如果不可编辑则阻止Backspace
            if ((tagName == 'INPUT' || tagName == 'TEXTAREA') && (obj.readOnly == true || obj.disabled == true)) {
                return stopIt(ev);
            }
        }
    }

    function stopIt(ev) {
        if (ev.preventDefault) {
            //preventDefault()方法阻止元素发生默认的行为
            ev.preventDefault();
        }
        if (ev.returnValue) {
            //IE浏览器下用window.event.returnValue = false;实现阻止元素发生默认的行为
            ev.returnValue = false;
        }
        return false;
    }

    //实现对字符码的截获，keypress中屏蔽了这些功能按键
    document.onkeypress = banBackSpace;
    //对功能按键的获取
    document.onkeydown = banBackSpace;

});

/**
 * 数据字典对象
 **/
var Dic = function () {
    return {
        /**
         * 根据字典码获取字典描述
         * @param dics 字典项列表
         * @param code 字典码
         * @returns {*}
         */
        showName: function (dics, code) {
            for (var i = 0; i < dics.length; i++) {
                if (dics[i].code + "" == code + "") {
                    return dics[i].name
                }
            }
        },
    };

}();
/**
 * 常规表格删除数据后，序号重新排序
 */
(function($){
	if($.fn.datagrid && $.fn.datagrid.methods){
		var deleteRow = $.fn.datagrid.methods.deleteRow;
		$.fn.datagrid.methods.deleteRow = function(jq,_8db){
			var result = deleteRow(jq,_8db);
			jq.each(function(){
				var data = $(this).datagrid("getRows");
				for(var i = 0; i < data.length; i++) {
					var editors = $(this).datagrid("getEditors", i);
					if(editors.length){
						var obj = [];
						for(var j = 0; j < editors.length; j++) {
							var ed = editors[j];
							obj.push(ed.actions.getValue(ed.target));
						}
						$(this).datagrid("refreshRow",i);
						$(this).datagrid("beginEdit",i);
						editors = $(this).datagrid("getEditors", i);
						for(var j = 0; j < editors.length; j++) {
							var ed = editors[j];
							ed.actions.setValue(ed.target, obj[j]);
						}
					} else {
						$(this).datagrid("refreshRow",i);
					}
				}
			});
			return result;
		}
	}
})(jQuery);
/**
 * 常规表格重新加载表格后去除之前勾选项
 */
(function($){
	if($.fn.datagrid && $.fn.datagrid.methods){
		var load = $.fn.datagrid.methods.load;
		$.fn.datagrid.methods.load = function(jq,_8bb){
			jq.each(function(){
				$(this).datagrid("clearSelections");
				$(this).datagrid("clearChecked");
			});
			var result = load(jq,_8bb);
			return result;
		}
	}
	if($.fn.treegrid && $.fn.treegrid.methods){
		var load_treegrid = $.fn.treegrid.methods.load;
		$.fn.treegrid.methods.load = function(jq,_8bb){
			jq.each(function(){
				$(this).treegrid("clearSelections");
				$(this).treegrid("clearChecked");
			});
			var result = load_treegrid(jq,_8bb);
			return result;
		}
	}
})(jQuery);


/**
 * 日期控件禁止选择某个日期
 */
(function($){
	
	if($.fn.combo && $.fn.combo.methods){
		var showPanel = $.fn.combo.methods.showPanel;
		$.fn.combo.methods.showPanel = function(jq){
			setCalendar(jq);
			return showPanel(jq);
		}
		function setCalendar(jq){
			if ($(jq).data('datebox')){
				var opt = $(jq).datebox("options");
				var c = $(jq).datebox("calendar");
				c.calendar({
					validator: function(date){
						return opt.disabledDate ? opt.disabledDate.call(jq[0],date) : true
					}
				});
			}
		}
	}
})(jQuery);

/**
 * form表单提交类路径属性处理
 */
(function($){
	
	if($.fn.form && $.fn.form.methods){
		var form = $.fn.form,
		submitFn = $.fn.form.methods.submit;
		fomatVal = function (param){
			if(param) param = App.delProperty(param,"@type",Infinity);
			// var formData = $(this).serializeArray(),obj = {};
			// if(formData) {
			// 	for(var i = 0; i < formData.length; i++) {
			// 		obj[formData[i].name] = formData[i].value;
			// 	}
			// 	obj = App.delProperty(obj,"@type",Infinity);
			// 	$(this).form("load",obj)
			// }
		};
		$.fn.form = function(options, param){
			if (typeof options == "object") {
				var onSubmit = options.onSubmit;
				options.onSubmit = function(pramas){
					var res = true;
					if(onSubmit) res = onSubmit.call(this,pramas);
					else res = $(this).form("validate");
					fomatVal.call(this,pramas);
					return res
				}
			}
			return form.call(this,options, param);
		}
		$.fn.form = Object.assign($.fn.form,form);
		$.fn.form.methods.submit = function(jq,pramas){
			if(pramas && pramas.onSubmit){
				var onSubmit = pramas.onSubmit;
				pramas.onSubmit = function(pramas){
					var res = onSubmit.call(this,pramas);
					fomatVal.call(this,pramas);
					return res;
				}
			}
			return submitFn.call(this,jq,pramas);
		}
	}
})(jQuery);

/**
 * 表格页面信息存储
 */
(function($){
	function optionSet(options){
		if (typeof options == "string" || !options) return;
		var loader,storageKey = "table_" + $(this).attr("id") + window.location.pathname;
		if(options.loader){
			loader = options.loader;
			options.loader = function(data,successfn,errorfn){
				window.localStorage.setItem(storageKey,JSON.stringify({
					page: data.page,
					rows: data.rows,
				}));
				loader.call(this,data,successfn,errorfn);
			};
		} else {
			options.loader = function(data,successfn,errorfn){
				window.localStorage.setItem(storageKey,JSON.stringify({
					page: data.page,
					rows: data.rows,
				}));
				var opts;
				if ($(this).data('treegrid')){
				    opts = $(this).treegrid("options");
				} else {
				    opts = $(this).datagrid("options");
				}
				if(!opts.url){
					return false;
				}
				$.ajax({type:opts.method,url:opts.url,data:data,dataType:"json",success:function(data){
						successfn(data);
					},error:function(){
						errorfn.apply(this,arguments);
					},
				});
			}
		}
		var pageInfo = window.localStorage.getItem(storageKey);
		if(pageInfo) {
			try{
				pageInfo = JSON.parse(pageInfo);
				if(pageInfo.page) options.pageNumber = pageInfo.page;
				if(pageInfo.rows) options.pageSize = pageInfo.rows;
			} catch(e){
				
			}
		}
	}
	if($.fn.datagrid){
		var datagrid = $.fn.datagrid;
		$.fn.datagrid = function(options, param){
			optionSet.call(this,options);
			return datagrid.call(this,options, param);
		}
		$.fn.datagrid = Object.assign($.fn.datagrid,datagrid);
	}
	if($.fn.treegrid){
		var treegrid = $.fn.treegrid;
		$.fn.treegrid = function(options, param){
			optionSet.call(this,options);
			return treegrid.call(this,options, param);
		}
		$.fn.treegrid = Object.assign($.fn.treegrid,treegrid);
	}
})(jQuery);
